<template>
  <div class="app-container">
    <!-- 查询区域 -->
    <el-form :model="queryParams" :ref="queryFormRef" inline v-show="showSearch" label-width="auto" @keyup.enter.native="handleQuery">
        <el-form-item label="关键字" prop="keywords" >
          <el-input v-model="queryParams.keywords" placeholder="请输入关键字" clearable />
        </el-form-item>
        <el-form-item label="店铺id" prop="id">
          <el-input-number v-model="queryParams.id" placeholder="店铺id" clearable />
        </el-form-item>
        <el-form-item label="店铺名称" prop="shopName">
          <lam-dict-select v-model="queryParams.shopName" dictCode="shop_name_type" placeholder="店铺名称" clearable />
        </el-form-item>
        <el-form-item label="店铺类型" prop="shopType">
          <el-input v-model="queryParams.shopType" placeholder="店铺类型" clearable />
        </el-form-item>
        <el-form-item label-width="0px">
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
    </el-form>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="tool-bar-btn">
      <el-button type="primary" icon="el-icon-plus" @click="handleAdd" v-hasPerms="['mall:shopDetail:add']">新增</el-button>
      <el-button type="success" icon="el-icon-edit" :disabled="single" @click="handleUpdate" v-hasPerms="['mall:shopDetail:edit']">修改</el-button>
      <el-button type="danger" icon="el-icon-delete" :disabled="multiple" @click="handleDelete" v-hasPerms="['mall:shopDetail:remove']">删除</el-button>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </div>
    
    <!-- 表格区域 -->
    <selected-info :count="selectedRows.length" :onClearSelected="onClearSelected" />
    <el-table :ref="dataTableRef" v-loading="loading" :data="dataList" stripe border @selection-change="onSelectChange" 
          :default-sort = "defaultSort" @sort-change="onSortChange" :row-key="rowKey">
      <el-table-column type="selection" width="55" align="center" fixed="left"/>
      <el-table-column label="编号" align="center" prop="id" sortable="custom" width="80"/>
      <el-table-column label="店铺名称" align="center" prop="shopNameDictText" width="120"/>
      <el-table-column label="店长用户id" align="center" prop="userId"  width="150" />
      <el-table-column label="店铺类型" align="center" prop="shopType"  width="150" />
      <el-table-column label="店铺简介" align="center" prop="intro" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="店铺公告" align="center" prop="shopNotice"  width="150" />
      <el-table-column label="店铺行业" align="center" prop="shopIndustry"  width="150" />
      <el-table-column label="店长" align="center" prop="shopOwner"  width="150" />
      <el-table-column label="店铺绑定的手机" align="center" prop="mobile"  width="150" />
      <el-table-column label="店铺联系电话" align="center" prop="tel"  width="150" />
      <el-table-column label="店铺所在纬度" align="center" prop="shopLat"  width="150" />
      <el-table-column label="店铺所在经度" align="center" prop="shopLng"  width="150" />
      <el-table-column label="店铺详细地址" align="center" prop="shopAddress"  width="150" />
      <el-table-column label="店铺所在省份" align="center" prop="province"  width="150" />
      <el-table-column label="店铺所在城市" align="center" prop="city"  width="150" />
      <el-table-column label="店铺所在区域" align="center" prop="area"  width="150" />
      <el-table-column label="店铺省市区代码，用于回显" align="center" prop="pcaCode"  width="150" />
      <el-table-column label="店铺logo" align="center" prop="shopLogo" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="店铺相册" align="center" prop="shopPhotos" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="每天营业时间段" align="center" prop="openTime"  width="150" />
      <el-table-column label="店铺状态" align="center" prop="shopStatusDictText" width="120"/>
      <el-table-column label="0:商家承担运费; 1:买家承担运费" align="center" prop="transportType"  width="150" />
      <el-table-column label="固定运费" align="center" prop="fixedFreight"  width="150" />
      <el-table-column label="满X包邮" align="center" prop="fullFreeShipping"  width="150" />
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180"/>
      <el-table-column label="分销开关" align="center" prop="isDistributionDictText" width="120"/>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="200">
        <template slot-scope="{row}">
          <el-button type="text" icon="el-icon-edit" @click="handleUpdate(row)" v-hasPerms="['mall:shopDetail:edit']">修改</el-button>
          <el-button type="text" icon="el-icon-delete" @click="handleDelete(row)" v-hasPerms="['mall:shopDetail:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination v-show="!loading" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"  @pagination="getList" />

    <!-- 添加或修改对话框 -->
    <EditShopDetail ref="formDialog" @ok="getList" />

  </div>
</template>

<script>
import {httpGet, httpDel} from '@/api';
import { IndexListMixin } from '@/components/mixins/IndexListMixin';
import EditShopDetail from './edit';

export default {
  name: "ShopDetail",
  mixins:[IndexListMixin],
  components: {
    EditShopDetail,
  },
  data() {
    return {
      // 查询参数
      queryParams: {
        keywords: null,
        id: null,
        shopNameKey: null,
        shopType: null,
        pageNum: 1,
        pageSize: 10
      },
      url: {
        base: '/mall/shopDetail/',
      	list: '/mall/shopDetail/list'
      }
    };
  },
  created() {
    this.getList();
  },
  mounted(){
  },
  methods: {
    getList() {
      this.loadData(this.url.list);
    },
    
    /** 新增按钮操作 */
    handleAdd() {
      this.$refs.formDialog.toAdd("添加店铺管理");
    },
    
    /** 修改按钮操作 */
    handleUpdate(row) {
      const id = row.id || this.selectedRowKeys
      this.$refs.formDialog.toUpdate("修改店铺管理", httpGet(this.url.base + id));
    },
    
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.selectedRowKeys
      this.deleteData(this.url.base, ids);
    },

  }
};
</script>
